package com.situ.blog.service.impl;

import com.situ.blog.mapper.*;
import com.situ.blog.pojo.vo.TypeCountVO;
import com.situ.blog.pojo.vo.UserCountVO;
import com.situ.blog.service.IChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ChartServiceImpl implements IChartService {
    @Autowired
    private ChartMapper chartMapper;

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private TypeMapper typeMapper;
    @Autowired
    private BlogMapper blogMapper;
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<TypeCountVO> selectTypeCount() {
        return chartMapper.selectTypeCount();
    }

    @Override
    public Map<String, Long> selectTotalCount() {
        Map<String, Long> map = new HashMap<String, Long>();
        Long userCount = userMapper.selectCount(null);
        Long typeCount = typeMapper.selectCount(null);
        Long blogCount = blogMapper.selectCount(null);
        Long commentCount = commentMapper.selectCount(null);
        map.put("userCount", userCount);
        map.put("typeCount", typeCount);
        map.put("blogCount", blogCount);
        map.put("commentCount", commentCount);
        return map;
    }

    @Override
    public List<UserCountVO> selectUserCount() {
        return chartMapper.selectUserCount();
    }
}
